ACP Implementation of PermissionsExt for Windows #152995
ACP Implementation of PermissionsExt for Windows #152995asder8215 wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
00739a8 to
2daf248
Compare
This comment has been minimized.
This comment has been minimized.
2daf248 to
29689a6
Compare
This comment has been minimized.
This comment has been minimized.
29689a6 to
b752775
Compare
This comment has been minimized.
This comment has been minimized.
b752775 to
23a096f
Compare
| /// let mut permissions = Permissions::set_file_attributes(my_file_attr); | ||
| /// assert_eq!(permissions.mode(), my_file_attr); | ||
| /// ``` | ||
| pub trait PermissionsExt { |
There was a problem hiding this comment.
Permissions struct doesn't have a Sealed trait bound (the Unix version of PermissionsExt doesn't use a Sealed trait bound either), so I'm unsure if this should be done here.
There was a problem hiding this comment.
Any new structs like this should be sealed. The reason the Unix version of PermissionExt doesn't is an historical artefact and one we'd love to fix. Otherwise it makes adding any functions a breaking change (this can be worked around by adding PermissionExt2 but we'd rather avoid that if possible).
This comment has been minimized.
This comment has been minimized.
23a096f to
3ed985e
Compare
This comment has been minimized.
This comment has been minimized.
3ed985e to
696ce60
Compare
| /// | ||
| /// // readonly and hidden file attributes that we | ||
| /// // want to add to existing file | ||
| /// let my_file_attr = 0x1 | 0x2; |
There was a problem hiding this comment.
Given this is a public example, this should use constants instead of magic values, even if that means defining the constants right about this line.
| /// ); | ||
| /// Ok(()) | ||
| /// } | ||
| /// ``` |
There was a problem hiding this comment.
Actually this whole example seems much more like a test than an example. I think it's better for users if examples are kept short and to the point.
| // According to SetFileAttributes, any other values | ||
| // passed to this should override FILE_ATTRIBUTE_NORMAL |
There was a problem hiding this comment.
Windows itself will override FILE_ATTRIBUTE_NORMAL if another attribute is present so I'm not sure it's necessary for us to do it. But if we do do it then I'd rather use a bitmask rather than repeating if self.normal() each time. Or maybe an internal-only helper function.
|
I'll get to updating this PR later today! To note, the doctest/example was inspired from the Unix version. I mirrored writing it in the way Unix doc for I'll try and see if I can apply the Thanks for taking a look at this PR @ChrisDenton! |
You should just be able implement
Yeah, after looking at the Unix example I do find that a bit verbose. In either case, considering the example is |
|
If there are no compilation errors, then yea I've added your feedback. Let me know if the doc comments for On a side note, I've been looking at |
This comment has been minimized.
This comment has been minimized.
I'm down to update the Unix example in a separate PR to reduce verbosity. As for testing the functions here, where would be the appropriate place to do that for this PR? Moreover, does CI here run Windows tests? I've been wondering that a bit because in my Reverse Ancestor PR, I have Windows tests there for paths with Prefix components, but I didn't see anything in CI that mentions that it ran my Windows test (and passes). |
|
You'll need to |
Oh okay, I could do that. I was worried that I may not be allowed to do that if it's a breaking change. |
b53af07 to
09f0506
Compare
… r=Mark-Simulacrum ACP Implementation of PermissionsExt for Windows This PR implements the `PermissionsExt` for Windows ACP and adds file attribute methods in `FilePermissions` struct (to be decided whether we use them or not). See this [tracking issue](rust-lang#152956 (comment)) for further detail and links. I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a `set_file_attributes()` + `from_file_attributes()` method to mirror what unix's `PermissionsExt` is doing). Also, some relevant links on this: * [File Attribute Constants](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants) * [`attrib` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib) * [SetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesa) * [GetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileattributesa) * [Window's File Attributes Column Values](https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values) * [What is the 'M' attribute in Windows file system for?](https://superuser.com/questions/1621649/what-is-the-m-attribute-in-windows-file-system-for) Note: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that. r? @ChrisDenton
Rollup of 8 pull requests Successful merges: - #155370 (Add regression test for dead code elimination with drop + panic) - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser) - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`) - #155431 (Add temporary scope to assert_matches) - #152995 (ACP Implementation of PermissionsExt for Windows ) - #153873 (deprecate `std::char` constants and functions) - #154654 (Move `std::io::ErrorKind` to `core::io`) - #154865 (libtest: use binary search for --exact test filtering)
… r=Mark-Simulacrum ACP Implementation of PermissionsExt for Windows This PR implements the `PermissionsExt` for Windows ACP and adds file attribute methods in `FilePermissions` struct (to be decided whether we use them or not). See this [tracking issue](rust-lang#152956 (comment)) for further detail and links. I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a `set_file_attributes()` + `from_file_attributes()` method to mirror what unix's `PermissionsExt` is doing). Also, some relevant links on this: * [File Attribute Constants](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants) * [`attrib` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib) * [SetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesa) * [GetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileattributesa) * [Window's File Attributes Column Values](https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values) * [What is the 'M' attribute in Windows file system for?](https://superuser.com/questions/1621649/what-is-the-m-attribute-in-windows-file-system-for) Note: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that. r? @ChrisDenton
Rollup of 9 pull requests Successful merges: - #155370 (Add regression test for dead code elimination with drop + panic) - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser) - #154972 (Implement `core::arch::return_address` and tests) - #155294 (Add test for coalescing of diagnostic attribute duplicates) - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`) - #155431 (Add temporary scope to assert_matches) - #152995 (ACP Implementation of PermissionsExt for Windows ) - #153873 (deprecate `std::char` constants and functions) - #154865 (libtest: use binary search for --exact test filtering)
… r=Mark-Simulacrum ACP Implementation of PermissionsExt for Windows This PR implements the `PermissionsExt` for Windows ACP and adds file attribute methods in `FilePermissions` struct (to be decided whether we use them or not). See this [tracking issue](rust-lang#152956 (comment)) for further detail and links. I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a `set_file_attributes()` + `from_file_attributes()` method to mirror what unix's `PermissionsExt` is doing). Also, some relevant links on this: * [File Attribute Constants](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants) * [`attrib` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib) * [SetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesa) * [GetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileattributesa) * [Window's File Attributes Column Values](https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values) * [What is the 'M' attribute in Windows file system for?](https://superuser.com/questions/1621649/what-is-the-m-attribute-in-windows-file-system-for) Note: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that. r? @ChrisDenton
Rollup of 10 pull requests Successful merges: - #155370 (Add regression test for dead code elimination with drop + panic) - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser) - #155294 (Add test for coalescing of diagnostic attribute duplicates) - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`) - #155431 (Add temporary scope to assert_matches) - #152995 (ACP Implementation of PermissionsExt for Windows ) - #153873 (deprecate `std::char` constants and functions) - #154865 (libtest: use binary search for --exact test filtering) - #154979 (add #[must_use] macros for floats) - #155504 (Remove `AttributeLintKind` variants - part 2)
|
Failed in rollup: #155511 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#155511), which was unapproved. |
This comment has been minimized.
This comment has been minimized.
ACP Implementation of PermissionsExt for Windows try-job: aarch64-msvc-1
|
💔 Test for 5618143 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
I think I need to put the feature flag inside the doctest |
…tilities to observe, set, and create a Permissions struct with certain file attributes
782a214 to
c567332
Compare
|
@rustbot ready |
|
@bors try jobs=aarch64-msvc-1 |
This comment has been minimized.
This comment has been minimized.
ACP Implementation of PermissionsExt for Windows try-job: aarch64-msvc-1

View all comments
This PR implements the
PermissionsExtfor Windows ACP and adds file attribute methods inFilePermissionsstruct (to be decided whether we use them or not). See this tracking issue for further detail and links.I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a
set_file_attributes()+from_file_attributes()method to mirror what unix'sPermissionsExtis doing).Also, some relevant links on this:
attribcommandNote: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that.
r? @ChrisDenton